package com.zsummer.demo.spring.rabbitmq.topic;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author zsummer
 * @since 2021/12/28
 */
@Component
public class TopicConsumer1 {

    @RabbitListener(
            bindings = @QueueBinding(
                    exchange = @Exchange(name = "ex.topic", type = ExchangeTypes.TOPIC),
                    value = @Queue("topic.q1"),
                    key = {"com.#"}
            )
    )
    public void directMsgHandle(String msg) {
        System.out.println("consumer1 " + msg);
    }
}
